// pages/driver/getMoney/getMoney.js
const handler = require("../../../utils/function.js");
var api = require("../../../api.js"),
    app = getApp();
Page({
    /**
     * 页面的初始数据
     */
    data: {
        price: '',
        banknum: '',
        bankname: '',
        pricey: wx.getStorageSync("price")
    },
    // intoPageHandler  页面跳转
    intoPageHandler: function(e) {
        console.log('提现申请参数', e)
        var that = this;
        app.request({
            url: api.user.apply,
            method: 'post',
            data: {
                price: that.data.price,
                bcard_num: that.data.banknum,
                bankname: that.data.bankname,
                type: 1 //提现到银行卡
            },
            success: function(rs) {
                console.log('提现申请结果', rs)
                if (rs.code == 1) {
                    handler.intoPageHandler(e.currentTarget.dataset.skip)
                } else {
                    wx.showToast({
                        title: rs.msg,
                        icon:'none',
                        mask:true
                    })
                }
            }
        })
        //handler.intoPageHandler(e.currentTarget.dataset.skip)
    },
    //获取提现金额
    getprice: function(e) {
        console.log('获取提现金额', e)
        this.setData({
            price: e.detail.value,
        })
    },
    //获取银行卡号
    getbanknum: function(e) {
        console.log('获取提现金额', e)
        this.setData({
            banknum: e.detail.value,
        })
    },
    //获取银行名称
    getbankname: function(e) {
        console.log('获取提现金额', e)
        this.setData({
            bankname: e.detail.value,
        })
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
      // 获取优惠券
      if (options.uid) {
        app.shareCouponsMessage(options.uid)
      }
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {},
    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {},
    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {},
    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {},
    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {},
  // 用户分享
  onShareAppMessage: function () {
    let title = app.shareAppMessage().title;
    let imageUrl = app.shareAppMessage().imageUrl;
    let desc = app.shareAppMessage().desc;
    let path = app.shareAppMessage().path;
    console.log(app.shareAppMessage())
    return {
      title: title,
      imageUrl: imageUrl,
      desc: desc,
      path: path,
    }
  },
})